package t05;

import java.util.Arrays;

/**
 * @author zhu
 * @date 2024-04-11
 */
public class MainTest01 {
    public static String[] build(int size,ArrayBuilder<String> builder){
        return builder.create(size);
    }
    public static void main(String[] args) {
        String[] arr1 = build(3, new ArrayBuilder<String>() {
            @Override
            public String[] create(int size) {
                return new String[size];
            }
        });
        arr1[0] = "aa" ;
        arr1[1] = "bb" ;
        arr1[2] = "cc" ;
        System.out.println(Arrays.toString(arr1));

        String[] arr2 = build(3,(size) -> {
            return new String[size];
        });

        arr2[0] = "ee" ;
        arr2[1] = "ff" ;
        arr2[2] = "gg" ;
        System.out.println(Arrays.toString(arr2));

        String[] arr3 = build(3,String[]::new);
        arr3[0] = "hh" ;
        arr3[1] = "ii" ;
        arr3[2] = "jj" ;
        System.out.println(Arrays.toString(arr3));
    }
}
